def sum_1_to_n(n):
    return n * (n + 1) // 2


if __name__ == '__main__':
    n = 1000
    n = n - 1
    limit_3 = n // 3
    limit_5 = n // 5
    limit_15 = n // 15
    print(3 * sum_1_to_n(limit_3) + 5 * sum_1_to_n(limit_5) - 15 * sum_1_to_n(limit_15))
